<?php

/**
 * Description of LessThan
 *
 * @author      Maciej Zawieja.
 * @link        http://akvus.pl
 * @package     Akvus Framework.
 * @subpackage  Libraries.
 * @copyright   2011 All rights reserved for Maciej Zawieja.
 * @version     1.0.0 - 19.08.2011 (Framework 1.3)
 */
class LessThan implements iValidation {

    const PARAMS_QUANTITY = 1;

    private $limit;

    public function isValid($text) {
        if ( !is_numeric( $text ) )
            throw new ValidationException ('Input muset be a number.', ValidationException::NOT_NUMBER);

        if ( $text >= $this->limit )
            throw new ValidationException('Numer is greater than or equal to limit.', ValidationException::TO_BIG);
    }

    public function setParams( array &$params ) {
        if ( count($params) < self::PARAMS_QUANTITY )
                throw new ProgrammerException ('Too less params for RegEx validation.', 0);

        $this->limit = $params[0];
    }

    function Limit( $limit = null )
    {
        if ($limit === null) return $this->limit;
        $this->limit = $limit;
        return $this;
    }
}